package com.kgc.sbt.service;

/**
 * Created on 2021/6/23.
 * <p>
 * Author: GongMingJie
 * <p>
 * Description: 抢购业务接口，用于redis存储和读取
 */
public interface BuyLimitService {

    /**
     * Created on 2021/6/23
     * Author: GongMingJie
     * @param
     * @return
     * Description: 初始化商品库存到redis
     */
    boolean initGoodsStockToRedis(String goodsId);

    /**
     * Created on 2021/6/23
     * Author: GongMingJie
     * @param
     * @return
     * Description: 锁定抢购用户
     */
    boolean lockBuyUser(String userId, String goodsId,Integer buyLimitId);

    /**
     * Created on 2021/6/23
     * Author: GongMingJie
     * @param
     * @return
     * Description: 校验商品库存
     */
    boolean checkProdStock(String goodsId, Integer buyCount);

    /**
     * Created on 2021/6/23
     * Author: GongMingJie
     * @param
     * @return
     * Description: 校验库存是否锁定
     */
    boolean isStockLock(String goodsId);

    /**
     * Created on 2021/6/23
     * Author: GongMingJie
     * @param
     * @return
     * Description: 校验订单是否生成
     */
    boolean isTradeOrderCreated(String tradeOrderNo);

    /**
     * Created on 2021/6/23
     * Author: GongMingJie
     * @param
     * @return
     * Description: 减库存
     */
    void subProdStockNum(String goodsId, Integer buyCount);

    /**
     * Created on 2021/6/23
     * Author: GongMingJie
     * @param
     * @return
     * Description: 释放库存锁
     */
    void unlockProdStockLock(String goodsId);


}
